package com.atguigu.sparkcore.day03.action

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object CollectDemo {
    def main(args: Array[String]): Unit = {
        val conf: SparkConf = new SparkConf().setAppName("CollectDemo").setMaster("local[2]")
        val sc: SparkContext = new SparkContext(conf)
        val list1 = List(30, 50, 70, 60, 10, 20)
        val rdd1: RDD[Int] = sc.parallelize(list1, 2)
        
        /*val arr: Array[Int] = rdd1.map(x => {
            println("map...")
            x
        }).filter(x => {
            println("filter...")
            true
        }).collect*/
        //        val s = rdd1.take(2)
        //        val s = rdd1.takeOrdered(2)(Ordering.Int.reverse)
//        val s: Array[Int] = rdd1.take(1)
//        val f: Int = rdd1.first()
        val s: Long = rdd1.count()
        println(s)
        
        sc.stop()
        
    }
}
